#include <stdio.h>  
#include <math.h>  
  
int main() {  
    long long a, n, ans = 1;  
    _Bool flag = 0;  
    if (scanf("%lld%lld", &a, &n));  
    a %= 1000;  
    while (n--) {  
        ans = ans * a;  
        if (ans > 999)  
            flag = 1;  
        ans %= 1000;  
    }  
  
    if (flag == 1)  
        printf("The last 3 numbers is %03lld.\n", ans);  
    else  
        printf("The last 3 numbers is %lld.\n", ans);  
    return 0;  
}  